package com.lzx.orderserver.config;

import org.reflections.Reflections;
import org.springframework.stereotype.Service;

import javax.annotation.PostConstruct;

/**
 * @author wb.liuzhengxing
 * @version v1.0
 * @package com.lzx.orderserver.config
 * @data 2022/8/25 18:09
 */
@Service
public class ClassCacheInitializing {

    private String packages = "com.lzx.orderserver.model";

    /**
     * 反射会有点耗时，所以程序启动的时候加载完放到缓存里面去,后面要用的时候直接去缓存取
     * @throws Exception
     */
    @PostConstruct()
    public void afterPropertiesSet() throws Exception {
        Reflections reflections = new Reflections(packages);
        ReflectionsCache.setReflections(reflections);
    }
}
